/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import data.DataProvider;
import java.sql.SQLException;
import org.json.JSONObject;

/**
 *
 * @author bertram
 */
public class ArtPhoto {
    private String path =  "";
    private String type = "";
    private int imageID;
    private boolean publicized = false;
    private String providedBy;
    private int workID = 0;
    public ArtPhoto()
    {
        try{
            this.imageID = DataProvider.getInstance().getNextBillede();

        }
        catch(SQLException sqx)
        {
           System.out.println("kunne ikke hente næste billed id");
        }
    }
    public ArtPhoto(int imageID)
    {
        this.imageID = imageID;
    }

    public int getImageID() {
        return imageID;
    }

    public void setImageID(int imageID) {
        this.imageID = imageID;
    }

    public String getPath() {
        if(path.equals(""))setType("image/jpeg");
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
        if(type.equalsIgnoreCase("image/jpeg") || type.equalsIgnoreCase("image/pjpeg"))path = imageID+".jpg";
        else if(type.equalsIgnoreCase("image/png"))path = imageID +".png";
        else if(type.equalsIgnoreCase("image/tiff"))path = imageID +".tif";
    }

    public boolean isPublicized() {
        return publicized;
    }

    public void setPublicized(boolean publicized) {
        this.publicized = publicized;
    }

    public String getProvidedBy() {
        return providedBy;
    }

    public void setProvidedBy(String providedBy) {
        this.providedBy = providedBy;
    }

    public JSONObject toJson()
    {
        JSONObject obj = new JSONObject(this);
        return obj;
    }

    public int getWorkID() {
        return workID;
    }

    public void setWorkID(int workID) {
        this.workID = workID;
    }

    

}
